package com.ruoyi.zsyh.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zsyh.domain.ZsyhServiceOrderSettleRepair;
import com.ruoyi.zsyh.service.IZsyhServiceOrderSettleRepairService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 师傅结算记录Controller
 * 
 * @author yuexl
 * @date 2022-09-15
 */
@Controller
@RequestMapping("/zsyh/serviceOrderSettleRepair")
public class ZsyhServiceOrderSettleRepairController extends BaseController
{
    private String prefix = "zsyh/serviceOrderSettleRepair";

    @Autowired
    private IZsyhServiceOrderSettleRepairService zsyhServiceOrderSettleRepairService;

    @RequiresPermissions("zsyh:serviceOrderSettleRepair:view")
    @GetMapping()
    public String serviceOrderSettleRepair()
    {
        return prefix + "/serviceOrderSettleRepair";
    }

    /**
     * 查询师傅结算记录列表
     */
    @RequiresPermissions("zsyh:serviceOrderSettleRepair:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZsyhServiceOrderSettleRepair zsyhServiceOrderSettleRepair)
    {
        startPage();
        List<ZsyhServiceOrderSettleRepair> list = zsyhServiceOrderSettleRepairService.selectZsyhServiceOrderSettleRepairList(zsyhServiceOrderSettleRepair);
        return getDataTable(list);
    }

    /**
     * 导出师傅结算记录列表
     */
    @RequiresPermissions("zsyh:serviceOrderSettleRepair:export")
    @Log(title = "师傅结算记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZsyhServiceOrderSettleRepair zsyhServiceOrderSettleRepair)
    {
        List<ZsyhServiceOrderSettleRepair> list = zsyhServiceOrderSettleRepairService.selectZsyhServiceOrderSettleRepairList(zsyhServiceOrderSettleRepair);
        ExcelUtil<ZsyhServiceOrderSettleRepair> util = new ExcelUtil<ZsyhServiceOrderSettleRepair>(ZsyhServiceOrderSettleRepair.class);
        return util.exportExcel(list, "师傅结算记录数据");
    }

    /**
     * 新增师傅结算记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存师傅结算记录
     */
    @RequiresPermissions("zsyh:serviceOrderSettleRepair:add")
    @Log(title = "师傅结算记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZsyhServiceOrderSettleRepair zsyhServiceOrderSettleRepair)
    {
        return toAjax(zsyhServiceOrderSettleRepairService.insertZsyhServiceOrderSettleRepair(zsyhServiceOrderSettleRepair));
    }

    /**
     * 修改师傅结算记录
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        ZsyhServiceOrderSettleRepair zsyhServiceOrderSettleRepair = zsyhServiceOrderSettleRepairService.selectZsyhServiceOrderSettleRepairById(id);
        mmap.put("zsyhServiceOrderSettleRepair", zsyhServiceOrderSettleRepair);
        return prefix + "/edit";
    }

    /**
     * 修改保存师傅结算记录
     */
    @RequiresPermissions("zsyh:serviceOrderSettleRepair:edit")
    @Log(title = "师傅结算记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZsyhServiceOrderSettleRepair zsyhServiceOrderSettleRepair)
    {
        return toAjax(zsyhServiceOrderSettleRepairService.updateZsyhServiceOrderSettleRepair(zsyhServiceOrderSettleRepair));
    }

    /**
     * 删除师傅结算记录
     */
    @RequiresPermissions("zsyh:serviceOrderSettleRepair:remove")
    @Log(title = "师傅结算记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zsyhServiceOrderSettleRepairService.deleteZsyhServiceOrderSettleRepairByIds(ids));
    }
}
